package com.zrk.oop;

/**
 * 从Java 15开始，允许使用sealed修饰class，并通过permits明确写出能够从该class继承的子类名称
 *  1.sealed 关键字指定某个类 Shape 只能被通过某几个类继承，且必须通过这几个类继承
 *  2.permits 关键字指明哪些类继承这个类
 *  3.继承自该类的类必须指定为
 *      - final
 *      - non-sealed
 *      - 或者再指定他将被谁继承
 */
public sealed class Shape permits Rect, Circle, Triangle {
    int length;

}

non-sealed class Rect extends Shape {
}

final class Circle extends Shape {

}

sealed class Triangle extends Shape permits TestPermits {

}

final class TestPermits extends Triangle{

}